package com.learning.spring.ioc.property.config;

import com.learning.spring.ioc.property.entity.Address;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

/**
 * ClassName: AddressConfig
 * Description:
 * Date: 2020/8/25 20:07 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
@Configuration
@ImportResource(locations = "classpath:02-ioc-property-source-placeholder-configurer.xml")
public class AddressConfig {

    @Value("${address.name}")
    private String name;

    /**
     * 使用 @Value("${...}") 赋值
     *
     * @return
     */
    @Bean
    public Address addressValueAnnotationPropertyPlaceholder() {
        Address address = new Address();
        address.setName(name);
        return address;
    }

}
